import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: resolve => require(['@/views/login.vue'], resolve)
  },
  {
    path: '/deskTop',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
	children:[
		{
		    path: 'home',
		    component: resolve => require(['@/views/deskTop/home.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		}
	]
  },
  //二维码设置
  {
    path: '/codeSet',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'codeIndex',
  		    component: resolve => require(['@/views/codeSet/codeIndex.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'二维码设置'
  			}
  		}
  	]
  },
  //二维码设置
    {
      path: '/activeSys',
      component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
    	children:[
    		{
    		    path: 'activeList',
    		    component: resolve => require(['@/views/activeSys/activeList.vue'], resolve),
    			meta:{
    				keepAlive:false,
    				title:'二维码设置'
    			}
    		},
			{
			    path: 'activeSet',
			    component: resolve => require(['@/views/activeSys/activeSet.vue'], resolve),
				meta:{
					keepAlive:false,
					title:'活动设置'
				}
			},
			{
			    path: 'subList',
			    component: resolve => require(['@/views/activeSys/subList.vue'], resolve),
				meta:{
					keepAlive:false,
					title:'提交列表'
				}
			}
    	]
    },
  //图片管理
  {
    path: '/imgSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'imgList',
  		    component: resolve => require(['@/views/imgSys/imgList.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'图片管理'
  			}
  		}
  	]
  },
  //个人中心
  {
    path: '/myCenter',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'myCenter',
  		    component: resolve => require(['@/views/myCenter/myCenter.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'个人中心'
  			}
  		}
  	]
  },
]

// 解决报错
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
// replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};




const router = new VueRouter({
  mode: 'hash',
  routes
})



export default router
